/*
 * Group:PrePool K9-357 
 * 8/2010
 */
package blo;

import dao.UsersDAO;

/**
 *
 */
public class UsersBLO {
	private UsersDAO userDAO = new UsersDAO();

	/**
	 * @param username
	 *            user's name
	 * @param password
	 *            old password
	 * @param newPassword
	 *            new password
	 * @return true if successful,false if fail
	 */
	public boolean changePassword(String username, String password,
			String newPassword) {
		return userDAO.changePassword(username, password, newPassword);
	}

	/**
	 * @param username
	 *            user's name
	 * @param password
	 *            user's password
	 * @param role
	 *            user's role
	 * @return true if successful,false if fail
	 */
	public boolean addUser(String username, String password, int role) {
		return userDAO.addUser(username, password, role);
	}

	/**
	 * @param userID
	 *            user's ID
	 * @return true if successful,false if fail
	 */
	public boolean deleteUser(int userID) {
		return userDAO.deleteUser(String.valueOf(userID));
	}

	/**
	 * @param username
	 *            user's name
	 * @param password
	 *            user's password
	 * @return a integer that is user's role
	 */
	public int isValid(String username, String password) {
		return userDAO.isValid(username, password);
	}

	/**
	 * @param username
	 *            user's name
	 * @param password
	 *            user's password
	 * @return a integer that is user's role
	 */
	public int login(String username, String password) {
		return userDAO.login(username, password);
	}

	/**
	 * @param username
	 *            user's name
	 * @return a integer that is user's role
	 */
	public int getRole(String username) {
		return userDAO.getRole(username);
	}

	/**
	 * @param name
	 *            user's name
	 * @return user's ID
	 */
	public int getUserIDByName(String name) {
		return userDAO.getUserIDByName(name);
	}
}
